package com.tz.fruit.entity;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
* 地址实体类
*/
@Entity
@Table(name="FRUIT_ADDRESS")
public class Address implements Serializable{
	private Long addressId;//地址ID
	
	private String province;//省
	private String city;//市
	private String area;//区
	private String detailAddress;//详细地址
	private String emailCode;//邮编
	private String reciver;//收件人
	private String tel;//手机号
	private String isDefault;//是否默认收货地址0：否  1：是

	private User user;//地址所属用户
	
	public Address() {
	}

	public Address(String province, String city, String area, String detailAddress, String emailCode, String reciver,
			String tel, String isDefault, User user) {
		super();
		this.province = province;
		this.city = city;
		this.area = area;
		this.detailAddress = detailAddress;
		this.emailCode = emailCode;
		this.reciver = reciver;
		this.tel = tel;
		this.isDefault = isDefault;
		this.user = user;
	}

	@Id
	@GeneratedValue
	public Long getAddressId() {
		return addressId;
	}

	public void setAddressId(Long addressId) {
		this.addressId = addressId;
	}
	
	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	public String getDetailAddress() {
		return detailAddress;
	}

	public void setDetailAddress(String detailAddress) {
		this.detailAddress = detailAddress;
	}

	public String getEmailCode() {
		return emailCode;
	}

	public void setEmailCode(String emailCode) {
		this.emailCode = emailCode;
	}

	public String getReciver() {
		return reciver;
	}

	public void setReciver(String reciver) {
		this.reciver = reciver;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getIsDefault() {
		return isDefault;
	}

	public void setIsDefault(String isDefault) {
		this.isDefault = isDefault;
	}
	@ManyToOne
	@JoinColumn(name="userId")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((addressId == null) ? 0 : addressId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Address other = (Address) obj;
		if (addressId == null) {
			if (other.addressId != null)
				return false;
		} else if (!addressId.equals(other.addressId))
			return false;
		return true;
	}



	@Override
	public String toString() {
		return "Address [addressId=" + addressId + ", province=" + province + ", city=" + city + ", area=" + area
				+ ", detailAddress=" + detailAddress + ", emailCode=" + emailCode + ", reciver=" + reciver + ", tel="
				+ tel + ", isDefault=" + isDefault + "]";
	}
	
}
